<template>
  <div>
    <div class="m-dataList">
      <el-table
        :data="dataList"
        ref="dataList"
        v-loading="dataListLoading"
        element-loading-text="loading..."
        :max-height="800"
        style="width: 100%"
      >
        <el-table-column
          prop="pno"
          width="200"
          label="提案号">
        </el-table-column>
        <el-table-column
          prop="proposal_status"
          label="提案状态"
          width="80">
          <template slot-scope="scope">
            {{scope.row.proposal_status | proposalStatus}}
          </template>
        </el-table-column>
        <el-table-column
          prop="proposal_date"
          label="提案时间"
          :formatter="countTimeFormat"
          width="160">
        </el-table-column>
        <el-table-column
          prop="approve_date"
          label="审批时间"
          :formatter="countTimeFormat"
          min-width="160">
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
  import * as LeadsAPI from '@/Api/lead';
  import * as Utils from '@/utils'
  export default {
    name: 'TheProposal',
    data () {
      return {
        dataList: [],
        dataListLoading:false,
      }
    },
    props:['type'],
    computed: {
      queryId(){
        return this.$route.params.id.split('_')[1]
      }
    },
    filters:{
      proposalStatus(val){
        if(val == '-3') {
            return '系统拒绝'
        }
        else if(val == '-2') {
          return '逾期 '
        }
        else if(val == '-1') {
          return '已取消'
        }
        else if(val == '0') {
          return '未审核'
        }
        else if(val == '1') {
          return '待审批'
        }
        else if(val == '2') {
          return '已审核'
        } else  {
            return val
        }
      }
    },
    methods: {
      queryList(){
        this.dataListLoading = true;
        if (this.$refs.dataList) {
          this.$refs.dataList.bodyWrapper.scrollTop = 0;
        }
        LeadsAPI.leadInfo2_2({
          queryId: this.queryId,
        })
          .then(res => {
            this.dataListLoading = false;
            if (res.code != '0') {
              this.$notify.warning({
                title: '温馨提示',
                message: res.msg
              })
              return
            }
            this.dataList = res.data;
          })
          .catch(error => {
            this.dataListLoading = false;
            console.log(error)
          })
      },
      countTimeFormat(row, column){
        return Utils.countDateTimeFormat(row[column.property])
      },
    },
    created(){
      this.queryList();
    }
  }
</script>

<style scoped lang="scss">
</style>
